class Solution(object):
    def findTheString(self, lcp):
        n = len(lcp)
        ans = [-1] * n
        base = 0
        for i in range(n):
            if ans[i] == -1:
                ans[i] = base
                for j in range(i + 1, n):
                    if lcp[i][j]:
                        if ans[j] == -1:
                            ans[j] = base
                        else:
                            return ''
                base += 1
        if base > 26:
            return ''
        for j in range(n - 1, -1, -1):
            for i in range(n - 1, -1, -1):
                if i == n - 1:
                    if j == n - 1:
                        if ans[i] == ans[j]:
                            now_val = 1
                        else:
                            now_val = 0
                        if now_val != lcp[i][j]:
                            return ''
                    else:
                        if ans[i] == ans[j]:
                            now_val = 1
                        else:
                            now_val = 0
                        if now_val != lcp[i][j]:
                            return ''
                else:
                    if j == n - 1:
                        if ans[i] == ans[j]:
                            now_val = 1
                        else:
                            now_val = 0
                        if now_val != lcp[i][j]:
                            return ''
                    else:
                        if ans[i] == ans[j]:
                            now_val = 1 + lcp[i + 1][j + 1]
                        else:
                            now_val = 0
                        if now_val != lcp[i][j]:
                            return ''
        ans = [chr(ord('a') + item) for item in ans]
        return ''.join(ans)
                        
data = Solution()
lcp = [[4,0,2,0],[0,3,0,1],[2,0,2,0],[0,1,0,1]]
print(data.findTheString(lcp))